{
  "properties" : { },
  "id" : "50236aff26934a6bb56f8d74298d81a4",
  "script" : null,
  "groupId" : "9c800c558ce64f189f6fb4c3df44bc9f",
  "name" : "查询历史告警列表",
  "createTime" : 1727070894009,
  "updateTime" : 1726646447715,
  "lock" : "0",
  "createBy" : "ndmp",
  "updateBy" : "ndmp",
  "path" : "list",
  "method" : "POST",
  "parameters" : [ ],
  "options" : [ ],
  "requestBody" : "{\n    \"current\": 1,\n    \"deviceId\": \"D1481718669032297212\",\n    \"needCalculate\": true,\n    \"size\": 10\n}",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : "{\n    \"status\": 200,\n    \"message\": \"success\",\n    \"data\": {\n        \"total\": 11,\n        \"current\": 1,\n        \"size\": 30,\n        \"records\": [\n            {\n                \"id\": \"1834541315530211328\",\n                \"alarmTarget\": \"D4132137890287528093\",\n                \"alarmRuleId\": \"99992\",\n                \"alarmTime\": \"2024-09-24 09:06:02\",\n                \"firstAlarmTime\": \"2024-09-24 09:06:02\",\n                \"alarmContent\": \"GigabitEthernet1/0/13 is UP\",\n                \"alarmCount\": \"3\",\n                \"isRecovery\": \"0\",\n                \"confirmTime\": \"\",\n                \"recoveryTime\": \"2024-09-24 09:06:02\",\n                \"confirmPerson\": \"\",\n                \"entity\": \"GigabitEthernet1/0/13\",\n                \"deviceName\": \"SN-YA.GaoTianLiangFD.R\",\n                \"deviceType\": \"1\",\n                \"typeName\": \"trap告警\",\n                \"alarmMetric\": \"链路断开\",\n                \"level\": \"1\",\n                \"levelName\": \"紧急\",\n                \"displayColor\": \"#EE1A1A\",\n                \"deptId\": \"7\",\n                \"deptName\": \"延安变接入\",\n                \"rowId\": \"1\"\n            },\n            {\n                \"id\": \"1834864680132435968\",\n                \"alarmTarget\": \"D1769297024146086962\",\n                \"alarmRuleId\": \"100006\",\n                \"alarmTime\": \"2024-09-12 16:32:26\",\n                \"firstAlarmTime\": \"2024-09-12 16:32:26\",\n                \"alarmContent\": \"设备实际带宽：22.5KB\",\n                \"alarmCount\": \"1\",\n                \"isRecovery\": \"0\",\n                \"confirmTime\": \"\",\n                \"recoveryTime\": \"\",\n                \"confirmPerson\": \"\",\n                \"entity\": \"device\",\n                \"deviceName\": \"SN2-YL.R1\",\n                \"deviceType\": \"1\",\n                \"typeName\": \"trap告警\",\n                \"alarmMetric\": \"设备带宽\",\n                \"level\": \"15\",\n                \"levelName\": \"提示\",\n                \"displayColor\": \"#33B9E4\",\n                \"deptId\": \"3\",\n                \"deptName\": \"骨干二平面\",\n                \"rowId\": \"2\"\n            },\n            {\n                \"id\": \"1834835115397951488\",\n                \"alarmTarget\": \"D1188322823268322549\",\n                \"alarmRuleId\": \"99993\",\n                \"alarmTime\": \"2024-09-12 16:32:26\",\n                \"firstAlarmTime\": \"2024-09-12 16:32:26\",\n                \"alarmContent\": \"设备实际带宽：22.5KB\",\n                \"alarmCount\": \"1\",\n                \"isRecovery\": \"0\",\n                \"confirmTime\": \"\",\n                \"recoveryTime\": \"\",\n                \"confirmPerson\": \"\",\n                \"entity\": \"device\",\n                \"deviceName\": \"SN-YA.HeZhuangKeGF.R\",\n                \"deviceType\": \"1\",\n                \"typeName\": \"trap告警\",\n                \"alarmMetric\": \"设备带宽\",\n                \"level\": \"1\",\n                \"levelName\": \"紧急\",\n                \"displayColor\": \"#EE1A1A\",\n                \"deptId\": \"7\",\n                \"deptName\": \"延安变接入\",\n                \"rowId\": \"3\"\n            },\n            {\n                \"id\": \"1834541582820622336\",\n                \"alarmTarget\": \"D4132137890287528093\",\n                \"alarmRuleId\": \"100006\",\n                \"alarmTime\": \"2024-09-12 16:32:26\",\n                \"firstAlarmTime\": \"2024-09-12 16:32:26\",\n                \"alarmContent\": \"设备实际带宽：22.5KB\",\n                \"alarmCount\": \"1\",\n                \"isRecovery\": \"1\",\n                \"confirmTime\": \"\",\n                \"recoveryTime\": \"2024-09-13 18:14:50\",\n                \"confirmPerson\": \"\",\n                \"entity\": \"device\",\n                \"deviceName\": \"SN-YA.GaoTianLiangFD.R\",\n                \"deviceType\": \"1\",\n                \"typeName\": \"trap告警\",\n                \"alarmMetric\": \"设备带宽\",\n                \"level\": \"15\",\n                \"levelName\": \"提示\",\n                \"displayColor\": \"#33B9E4\",\n                \"deptId\": \"7\",\n                \"deptName\": \"延安变接入\",\n                \"rowId\": \"4\"\n            },\n            {\n                \"id\": \"1834538927738109952\",\n                \"alarmTarget\": \"D4132137890287528093\",\n                \"alarmRuleId\": \"99993\",\n                \"alarmTime\": \"2024-09-12 16:32:26\",\n                \"firstAlarmTime\": \"2024-09-12 16:32:26\",\n                \"alarmContent\": \"设备实际带宽：22.5KB\",\n                \"alarmCount\": \"1\",\n                \"isRecovery\": \"0\",\n                \"confirmTime\": \"\",\n                \"recoveryTime\": \"\",\n                \"confirmPerson\": \"\",\n                \"entity\": \"device\",\n                \"deviceName\": \"SN-YA.GaoTianLiangFD.R\",\n                \"deviceType\": \"1\",\n                \"typeName\": \"trap告警\",\n                \"alarmMetric\": \"设备带宽\",\n                \"level\": \"1\",\n                \"levelName\": \"紧急\",\n                \"displayColor\": \"#EE1A1A\",\n                \"deptId\": \"7\",\n                \"deptName\": \"延安变接入\",\n                \"rowId\": \"5\"\n            },\n            {\n                \"id\": \"1834835115448283136\",\n                \"alarmTarget\": \"D1188322823268322549\",\n                \"alarmRuleId\": \"100006\",\n                \"alarmTime\": \"2024-09-12 16:32:26\",\n                \"firstAlarmTime\": \"2024-09-12 16:32:26\",\n                \"alarmContent\": \"设备实际带宽：22.5KB\",\n                \"alarmCount\": \"1\",\n                \"isRecovery\": \"0\",\n                \"confirmTime\": \"\",\n                \"recoveryTime\": \"\",\n                \"confirmPerson\": \"\",\n                \"entity\": \"device\",\n                \"deviceName\": \"SN-YA.HeZhuangKeGF.R\",\n                \"deviceType\": \"1\",\n                \"typeName\": \"trap告警\",\n                \"alarmMetric\": \"设备带宽\",\n                \"level\": \"15\",\n                \"levelName\": \"提示\",\n                \"displayColor\": \"#33B9E4\",\n                \"deptId\": \"7\",\n                \"deptName\": \"延安变接入\",\n                \"rowId\": \"6\"\n            },\n            {\n                \"id\": \"1834835019566493696\",\n                \"alarmTarget\": \"D1173111724299330511\",\n                \"alarmRuleId\": \"99993\",\n                \"alarmTime\": \"2024-09-12 16:32:26\",\n                \"firstAlarmTime\": \"2024-09-12 16:32:26\",\n                \"alarmContent\": \"设备实际带宽：22.5KB\",\n                \"alarmCount\": \"1\",\n                \"isRecovery\": \"0\",\n                \"confirmTime\": \"\",\n                \"recoveryTime\": \"\",\n                \"confirmPerson\": \"\",\n                \"entity\": \"device\",\n                \"deviceName\": \"SN-YL.TianJiaZhaiFD.R\",\n                \"deviceType\": \"1\",\n                \"typeName\": \"trap告警\",\n                \"alarmMetric\": \"设备带宽\",\n                \"level\": \"1\",\n                \"levelName\": \"紧急\",\n                \"displayColor\": \"#EE1A1A\",\n                \"deptId\": \"8\",\n                \"deptName\": \"榆林变接入\",\n                \"rowId\": \"7\"\n            },\n            {\n                \"id\": \"1836212390370500608\",\n                \"alarmTarget\": \"D1113602235964814951\",\n                \"alarmRuleId\": \"99993\",\n                \"alarmTime\": \"2024-09-12 16:32:26\",\n                \"firstAlarmTime\": \"2024-09-12 16:32:26\",\n                \"alarmContent\": \"设备实际带宽：22.5KB\",\n                \"alarmCount\": \"1\",\n                \"isRecovery\": \"0\",\n                \"confirmTime\": \"2024-09-18 09:15:24\",\n                \"recoveryTime\": \"\",\n                \"confirmPerson\": \"\",\n                \"entity\": \"device\",\n                \"deviceName\": \"SN-YA.NuanYangGF.R\",\n                \"deviceType\": \"1\",\n                \"typeName\": \"trap告警\",\n                \"alarmMetric\": \"设备带宽\",\n                \"level\": \"1\",\n                \"levelName\": \"紧急\",\n                \"displayColor\": \"#EE1A1A\",\n                \"deptId\": \"9\",\n                \"deptName\": \"榆横-夏州汇聚接入\",\n                \"rowId\": \"8\"\n            },\n            {\n                \"id\": \"1834865106240167936\",\n                \"alarmTarget\": \"D1919858423792924342\",\n                \"alarmRuleId\": \"99992\",\n                \"alarmTime\": \"2024-07-28 10:49:22\",\n                \"firstAlarmTime\": \"2024-07-28 10:49:22\",\n                \"alarmContent\": \"GigabitEthernet1/0/13 is UP\",\n                \"alarmCount\": \"1\",\n                \"isRecovery\": \"0\",\n                \"confirmTime\": \"\",\n                \"recoveryTime\": \"\",\n                \"confirmPerson\": \"\",\n                \"entity\": \"GigabitEthernet1/0/13\",\n                \"deviceName\": \"SN2.AK.R1\",\n                \"deviceType\": \"1\",\n                \"typeName\": \"trap告警\",\n                \"alarmMetric\": \"链路断开\",\n                \"level\": \"1\",\n                \"levelName\": \"紧急\",\n                \"displayColor\": \"#EE1A1A\",\n                \"deptId\": \"3\",\n                \"deptName\": \"骨干二平面\",\n                \"rowId\": \"9\"\n            },\n            {\n                \"id\": \"1834865687679754240\",\n                \"alarmTarget\": \"D1188322823268322549\",\n                \"alarmRuleId\": \"99992\",\n                \"alarmTime\": \"2024-07-28 10:49:22\",\n                \"firstAlarmTime\": \"2024-07-28 10:49:22\",\n                \"alarmContent\": \"GigabitEthernet1/0/13 is UP\",\n                \"alarmCount\": \"1\",\n                \"isRecovery\": \"0\",\n                \"confirmTime\": \"2024-09-14 16:04:05\",\n                \"recoveryTime\": \"\",\n                \"confirmPerson\": \"\",\n                \"entity\": \"GigabitEthernet1/0/13\",\n                \"deviceName\": \"SN-YA.HeZhuangKeGF.R\",\n                \"deviceType\": \"1\",\n                \"typeName\": \"trap告警\",\n                \"alarmMetric\": \"链路断开\",\n                \"level\": \"1\",\n                \"levelName\": \"紧急\",\n                \"displayColor\": \"#EE1A1A\",\n                \"deptId\": \"7\",\n                \"deptName\": \"延安变接入\",\n                \"rowId\": \"10\"\n            },\n            {\n                \"id\": \"1834864513522098176\",\n                \"alarmTarget\": \"D1153460434222107287\",\n                \"alarmRuleId\": \"99992\",\n                \"alarmTime\": \"2024-07-28 10:49:22\",\n                \"firstAlarmTime\": \"2024-07-28 10:49:22\",\n                \"alarmContent\": \"GigabitEthernet1/0/13 is UP\",\n                \"alarmCount\": \"2\",\n                \"isRecovery\": \"1\",\n                \"confirmTime\": \"\",\n                \"recoveryTime\": \"2024-09-14 11:15:30\",\n                \"confirmPerson\": \"\",\n                \"entity\": \"GigabitEthernet1/0/13\",\n                \"deviceName\": \"SN-WN.YanJiaFD.R\",\n                \"deviceType\": \"1\",\n                \"typeName\": \"trap告警\",\n                \"alarmMetric\": \"链路断开\",\n                \"level\": \"1\",\n                \"levelName\": \"紧急\",\n                \"displayColor\": \"#EE1A1A\",\n                \"deptId\": \"11\",\n                \"deptName\": \"信义变接入\",\n                \"rowId\": \"11\"\n            }\n        ]\n    }\n}",
  "description" : "",
  "requestBodyDefinition" : {
    "name" : "",
    "value" : { },
    "description" : "",
    "required" : false,
    "dataType" : "String",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ ]
  },
  "responseBodyDefinition" : {
    "name" : "",
    "value" : { },
    "description" : "",
    "required" : false,
    "dataType" : "String",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ ]
  }
}
================================
sql = """
    select info.*, dev.device_name, dev.device_type, ty.type_name, met.metirc_name alarm_metric,
    leve.level,leve.level_name, leve.display_color, grou.id dept_id,grou.group_name dept_name
	from alarm_info_history info 
	left join ndmp_device dev on dev.ID = info.alarm_target
	left join alarm_rule ru on ru.id = info.alarm_rule_id
	left join alarm_metric met on met.id = ru.rule_metric_id
	left join alarm_type ty on ty.id = met.metirc_type_id
	left join alarm_level leve on leve.level = ru.level
	left join NDMP_GROUP_DEVICE_RELATION rel on rel.device_id = dev.id
	left join NDMP_GROUP grou on grou.id = rel.group_id
    where 1 = 1
    <if test=" body.deviceId != null and body.deviceId != '' ">
        and dev.id = #{body.deviceId}
    </if>
    <if test=" body.deptName != null and body.deptName != '' ">
        and grou.group_name = #{body.deptName}
    </if>
    <if test=" body.alarmTarget != null and body.alarmTarget != '' ">
        and dev.device_name like concat('%', #{body.alarmTarget},'%')
    </if>
    <if test=" body.alarmTypeName != null and body.alarmTypeName != '' ">
        and ty.id = CAST(#{body.alarmTypeName} as int)
    </if>
    <if test=" body.alarmMetric != null and body.alarmMetric != '' ">
        and met.id = #{body.alarmMetric}
    </if>
    <if test=" body.levelId != null and body.levelId != '' ">
        and leve.level = #{body.levelId}
    </if>
    <if test=" body.isSolved != null">
        and info.is_recovery = #{body.isSolved}
    </if>
    <if test=" body.alarmContent != null and body.alarmContent != '' ">
        and info.alarm_content like concat('%', #{body.alarmContent},'%')
    </if>
    <if test="body.alarmStartTime != null and body.alarmStartTime != ''">
        AND info.confirm_time > to_timestamp(#{body.alarmStartTime},'yyyy-mm-dd hh24:mi:ss')
    </if>
    <if test="body.alarmEndTime != null and body.alarmEndTime != ''">
        AND info.confirm_time <= to_timestamp(#{body.alarmEndTime},'yyyy-mm-dd hh24:mi:ss')
    </if>
    <if test=" body.number != null">
        and info.alarm_count = #{body.number}
    </if>
    order by info.alarm_time desc
    
"""

return db.page(sql)